// JavaScript Document

function popup(){
	window.open("../aggiunta/sceglicontenuto.html","nome","menubar=yes,status=no,location=no,width=800,height=500");	
}

function setVisibleElement(div){
	if(document.getElementById(div).style.display == "block"){
		document.getElementById(div).style.display ='none';	
	}
	else {
	document.getElementById(div).style.display = 'block';
	}
}

function nascondi(div){
	document.getElementById(div).style.display = 'none';
	}

function setVisible(div1, div2){
	if(document.getElementById(div1).style.display == "block"){
		document.getElementById(div1).style.display ="none";	
	}
	document.getElementById(div2).style.display = "block";
}
function setTitle(){
	if(document.getElementById("p-container").style.display == "block"){
		document.getElementById("p-container").style.display ="none";	
	}
	document.getElementById("title-container").style.display = "block";	
}

function setP(){
	if(document.getElementById("title-container").style.display == "block"){
		document.getElementById("title-container").style.display ="none";	
	}
	document.getElementById("p-container").style.display = "block";	
}

function addStyle(stile){
	document.modulo_paragrafo.testo.value+=stile;
}
function addLink(nome,url){
	nome= document.getElementById(nome).value;
	url= document.getElementById(url).value;
	document.modulo_paragrafo.testo.value+= '<a href="http://'+url+'">'+nome+'</a>';
}


function controllaVuoti(modulo, id1, id2, mess){
	var cont=0;
	mod=document.getElementById(modulo);
	if(mod.nome.value.length==0){
		document.getElementById(id1).style.color="#C00";
		cont++;
	} else {
		document.getElementById(id1).style.color="#000";
	}
	if(mod.testo.value.length==0){
		document.getElementById(id2).style.color="#C00";
		cont++;	
	} else {
		document.getElementById(id2).style.color="#000";
	}
	
	if(cont!=0) {
		document.getElementById(mess).style.display="block";
		return false;
	} 
	document.getElementById(mess).style.display="none";
	return true;
}

function sostituisci(modulo){
	var mod=document.getElementById(modulo);
	var t = mod.testo.value;
	var r = t.replace(/\n/g,"<br />");
	mod.testo.value=r;
}